package org.skywork.top.flow.controller;

import org.flowable.task.api.Task;
import org.skywork.top.flow.service.IFlowableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/process")
public class ProcessController {

    @Autowired
    private IFlowableService flowableService;

    @PostMapping("/start")
    public String startProcess() {
        flowableService.startProcess();
        return "流程已启动";
    }

    @GetMapping("/tasks")
    public List<Task> getTasks(@RequestParam String assignee) {
        return flowableService.getTasks(assignee);
    }

    @PostMapping("/complete")
    public String completeTask(@RequestParam String taskId) {
        flowableService.completeTask(taskId);
        return "任务已完成";
    }
}